#if !defined(ximera_scripting_lua_virtualmachine_hpp)
#define ximera_scripting_lua_virtualmachine_hpp

// -----------------------------------------------------------

#include <ximera/scripting/ivirtualmachine.hpp>
#include <ximera/scripting/lua/lua.hpp>
#include <ximera/scripting/lua/script.hpp>

namespace ximera { namespace scripting { namespace lua
{
    class XIMERA_PLUGIN_API VirtualMachine : public IVirtualMachine
    {
    public:
        VirtualMachine();
        virtual ~VirtualMachine();

        virtual Language language() const;

        virtual void run(SharedPtr<IScript> const& script);
        virtual void run(IScript* script);
        virtual void run(String const& data);

    private:
        lua_State* _state;
        String _lastError;

        void grabError();
        void run(std::string const& data);

        void bindBaseLib();
        void bindMathLib();
        void bindXmlLib();
    };
}}}

// -----------------------------------------------------------

#endif